package com.ecommerce.order.entity;

import com.ecommerce.common.entity.BaseEntity;
import jakarta.persistence.*;
import lombok.Data;
import lombok.EqualsAndHashCode;

import java.math.BigDecimal;

/**
 * 订单项实体类
 */
@Data
@EqualsAndHashCode(callSuper = true)
@Entity
@Table(name = "order_items")
public class OrderItem extends BaseEntity {

    /**
     * 订单ID
     */
    @Column(nullable = false)
    private Long orderId;

    /**
     * 产品ID
     */
    @Column(nullable = false)
    private Long productId;

    /**
     * 产品名称
     */
    @Column(nullable = false, length = 100)
    private String productName;

    /**
     * 产品图片
     */
    @Column(length = 200)
    private String productImage;

    /**
     * 产品单价
     */
    @Column(nullable = false, precision = 10, scale = 2)
    private BigDecimal productPrice;

    /**
     * 购买数量
     */
    @Column(nullable = false)
    private Integer quantity;

    /**
     * 小计金额
     */
    @Column(nullable = false, precision = 10, scale = 2)
    private BigDecimal subtotal;
}